from django.conf.urls import url
from rest_framework_jwt.views import obtain_jwt_token
from rest_framework.routers import DefaultRouter

from . import views

urlpatterns = [
    url(r'^users/$', views.UserView.as_view()),

    # 用户名&手机号是否注册过的实时校验
    url(r'^mobiles/(?P<mobile>1[3-9]\d{9})/count/$', views.MobileCountView.as_view()),
    url(r'^usernames/(?P<username>\w{5,20})/count/$', views.UsernameCountView.as_view()),

    url(r'^authorizations/$', obtain_jwt_token),  # 内部封装好了登录签发JWT的视图逻辑
    url(r'^user/$', views.UserDetailView.as_view()),  # 用户中心详情视图
    url(r'^email/$', views.EmailView.as_view()),  # 保存邮箱
    url(r'^emails/verification/$', views.VerifyEmailView.as_view()),  # 验证邮箱(激活邮箱)
]


# 创建一个路由器
router = DefaultRouter()
router.register(r'addresses', views.AddressViewSet, base_name='addresses')

urlpatterns += router.urls

# POST /addresses/ 新建  -> create
# PUT /addresses/<pk>/ 修改  -> update
# GET /addresses/  查询  -> list
# DELETE /addresses/<pk>/  删除 -> destroy
# PUT /addresses/<pk>/status/ 设置默认 -> status
# PUT /addresses/<pk>/title/  设置标题 -> title
